/*
 * window.h
 *
 *  Created on: 2013. 5. 2.
 *      Author: ozarwork@gmail.com
 *        Note: This is a game window
 *        		I'm not good at win32api, so I referred to
 *        		 -> http://www.relisoft.com/win32/winnie.html
 */

#ifndef WINDOW_H
#define WINDOW_H

#include "resource.h"
#include "def.h"
#include "windowview.h"
#include "windowmodel.h"

class WindowView;
class WindowModel;

class Window
{
public:
	virtual ~Window();

	void ShowWindow();
	HWND getHWND();

protected:
	HINSTANCE		_hAppInstance;
	LPCTSTR			_appClassName;
    WNDCLASS		_wndClass;
    WNDPROC			_wndProcedure;
    HWND			_hWnd;
    LPCTSTR			_wndCaption;
    WindowView		*_wView		= 0;			// MVC-VIEW
    WindowModel		*_wModel	= 0;			// MVC-MODEL

	// ctor
	Window(LPCTSTR appClassName, LPCTSTR wndCaption);

    /* Following functions are mendatory */
	// Register(), We'll register windows of this _wndClass in our program
    void Register();
    // Create(), And then we'll creates window of given _wndClass
    HWND Create();
    // Show(), It shows you window
    void Show(int cmdShow);
    // MessageLoop(), The window goes into a message loop
    void MessageLoop();

	virtual LRESULT CALLBACK WindowProcedure
		(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) = 0;

private:
	// It processes any window messages
    static LRESULT CALLBACK StaticWindowProcedure
		(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
};

#endif /* WINDOW_H */
